<!--# layout("/common/layout.html",{"jsBase":"/js/promote/promoteLink/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" lay-filter="editform">
    <input type="hidden" name="linkId" id="linkId">

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">链接名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="linkName" id="linkName" autocomplete="off" maxlength="30" class="layui-input"
                           lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">链接地址</label>
                <div class="layui-input-inline" style="width:512px">
                    <input type="text" name="linkAddr" id="linkAddr" maxlength="50" autocomplete="off" class="layui-input"
                           lay-verify="required">
                </div>
            </div>

        </div>
    </div>
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">可用状态</label>
                <div class="layui-input-inline">
                    <input type="radio" name="linkStatus" value="1" title="是">
                    <input type="radio" name="linkStatus" value="0" title="否">

                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">分享模板</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="templateId" value="${has(promoteLink)?promoteLink.templateId:''}" data="${templateIdList}"
                                            attrId="templateId" attrName="templateName" />
                </div>
            </div>
        </div>

    </div>
    <layui:submitButtons id="addButton"/>
</form>
<!--#} -->
<script>
    layui.define(['form', 'laydate', 'table', 'promoteLinkApi'], function (exports) {
        var form = layui.form;
        var promoteLinkApi = layui.promoteLinkApi;
        var index = layui.index;
        var isNew = true;
        <!--# if(!(isEmpty(promoteLinkJson))){  -->
        isNew = false;
        <!--# } -->
        var view = {
            init: function () {
                Lib.initGenrealForm($("#addForm"), form);
                this.initSubmit();
            },
            initSubmit: function () {
                $("#addButton").click(function () {
                    form.on('submit(form)', function () {
                        promoteLinkApi.saveForm(isNew, $('#addForm'), function () {
                            parent.window.dataReload();
                            Common.info("保存成功");
                            Lib.closeFrame();
                        });
                    });
                });

                $("#addButton-cancel").click(function () {
                    Lib.closeFrame();
                });
            }

        }
        view.init();
        <!--# if(!(isEmpty(promoteLinkJson))){  -->
        var formJson = ${promoteLinkJson};
        form.val("editform", formJson);
        <!--# } -->
    });
</script>
